<?php
/**
 * @version 1.0
 * @since Aug-2008
 * @package lib
 * @subpackage struct
 * @name CFile 
 * @deprecated Lớp thao tác với upload file
*/
require_once 'CUpload.php';
class CFtpUpload extends CUpload
{
	function __construct($dir_name, $input_name, $prefix)
	{
		parent::__construct($dir_name, $input_name, $prefix);
	}
	function file_treatment($path, $file_name)
	{
		$new_dir = CFile(FTP_PREFIX.$path)->mkdir();
		$fp = fopen($path.$file_name, 'r');
		$result = ftp_fput(CFile::ftp_connection_id(), $path.$file_name, $fp, FTP_BINARY);
		fclose($fp);
		return $result;
	}
	static function delete($filename, $upload_dir=""){
		if(empty($upload_dir)){
			if(strpos($filename, "http://")!==false){
				$filename = strstr($filename, 'upload/');
			}
		}
		if(CFile::exists(FTP_PREFIX.$upload_dir . $filename)){
			if(CFile::exists($upload_dir . $filename)){
				@unlink($upload_dir . $filename);
			}
			return @unlink(FTP_PREFIX.$upload_dir . $filename);
		}else{
			return false;
		}
	}
}
/**
 * Hàm tạo đối tượng CFile
 * @return CFile đối tượng CFile mới tạo
 */
function CFtpUpload($dir_name, $input_name, $prefix)
{
	return new CFtpUpload($dir_name,$input_name, $prefix);
}
?>